package debtbundler.domain.entity;

import java.util.Set;

/**
 * Person who pays and shares costs with other persons.
 * 
 * @author Anssi
 *
 */
public interface Person extends MoneyPool {
	
	/**
	 * @param name	name of this person
	 */
	public void setName(String name);	

	/**
	 * Returns the payments by this person for shared costs.
	 *  
	 * @return	payments by this person
	 */
	public Set<Payment> getPayments();	

	/**
	 * Returns this person's shares of pooled costs.
	 *  
	 * @return	 this person's shares of pooled costs
	 */	
	public Set<Share> getShares();

	/**
	 * Adds a payment paid by this person for a shared cost.
	 * <p>
	 * For data consistency, implementations of this interface must 
	 * ensure that the payment is added to the sharedCost as well.
	 * 
	 * @param payment	the payment to add
	 * @return			<code>true</code> if the payment was added
	 */
	public boolean addPayment(Payment payment);

	/**
	 * Adds a share of costs to this person.
	 * <p>
	 * For data consistency, implementations of this interface must 
	 * ensure that the share is added to the sharedCost as well.
	 * 
	 * @param share	the share to add
	 * @return		<code>true</code> if the share was added
	 */
	public boolean addShare(Share share);	
	
	/**
	 * Returns the debts owed by or owed to this person.
	 * 
	 * @return	the debts owed by or owed to this person
	 */
	public Set<Debt> getDebts();
	
	/**
	 * Adds a debt owed by or owed to this person.
	 * 
	 * @param debt	the debt to add
	 * @return		<code>true</code> if the debt was added
	 */
	public boolean addDebt(Debt debt);	

	/**
	 * Returns the difference between payments and cost shares of this person.
	 * <p>
	 * Costs are valued as negative, shares as positive. Therefore
	 * negative value means money is owed to others by this person.
	 * 
	 * @return	cost balance of this person. Negative value means 
	 * 			money is owed to others by this person.
	 */
	public double getCostBalance();
	
}
